package com.hbue.springboot.config;

import com.hbue.springboot.Interceptor.JWTInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 功能：
 * 日期：2025/1/13 14:04
 */
@Configuration
@Slf4j
public class WaterConfig implements WebMvcConfigurer {

    /**
     * 创建JWTInterception拦截器拦截所有请求，排除账户服务的请求
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("-------------------------JWT Interceptor---------------------------------");
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/customer/**")
                .addPathPatterns("/worker/**")
                .addPathPatterns("/history/**")
                .addPathPatterns("/account/**")
                .excludePathPatterns("/account/login");
    }
}
